<template>
  <div class="statistics">
    <div class="index" :style="{'background': backgroundList[statisticsIndex]}">{{statisticsIndex + 1}}st</div>
    <div class="title" :style="{color: statisticsIndex<3 ? '#fff08d':'white'}">{{title}}</div>
    <div class="bg">
      <img :style="{'margin-left': `-${200-200*data/100}%`}" src="../../assets/screen/rainbow_bar.png"/>
    </div>
  </div>
</template>

<script>
export default {
  // 全局感知
  name: "",

  // 模板依赖
  components: {},
  filters: {},

  // 接口
  props: {
    statisticsIndex: Number,
    title: String,
    data: Number
  },

  // 本地状态
  data() {
    return {
      backgroundList: [
        "#ff0000",
        "#ffae00",
        "#13cb00",
        "rgba(46, 139, 87, 0)",
        "rgba(46, 139, 87, 0)"
      ]
    };
  },
  computed: {},
  // 事件
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  // 非响应式的属性
  methods: {}
};
</script>

<style lang="scss" scoped>
.statistics {
  position: relative;
  margin-top: 0.5rem;
  width: 95%;
  height: 3rem;
  font-size: 2rem;
  line-height: 3rem;
  .index {
    position: relative;
    float: left;
    width: 10%;
    margin: 0.5rem 0 0.5rem 4.5%;
    line-height: 2rem;
    color: white;
    border-radius: 1rem;
  }
  .title {
    position: relative;
    float: left;
    width: 30.5%;
    text-align: center;
    color: white;
  }
  .bg {
    position: relative;
    margin-top: 0.5rem;
    float: left;
    width: 55%;
    height: 2rem;
    border-radius: 0.8rem;
    background: rgba(100, 113, 151, 0.7);
    overflow: hidden;
    img {
      position: relative;
      width: 100%;
      height: 2rem;
      transition: all 1s;
    }
  }
}
</style>
